﻿using Models;
using System.Collections.Generic;
using System.Web.Http;

namespace WebApp.Controllers
{
    [RoutePrefix("api/Tag")]
    public class TagABCController : ApiController
    {
        Services.TagServices services = new Services.TagServices();

        [HttpGet]
        [Route("GetAll")]
        public IHttpActionResult GetAll()
        {
            List<Tag> list = services.GetList(t => t.TagName != "");
            return Json(list);
        }

        [HttpPost]
        [Route("Save")]
        public int Save(Tag objTag)
        {
            return services.Save(objTag);
        }

        [HttpPost]
        [Route("Delete")]
        public int Delete(string id)
        {
            return services.Delete(id);
        }

        [HttpPost]
        [Route("Exists")]
        public bool Exists(Tag objTag)
        {
            return services.Exists(t => t.TagName == objTag.TagName && t.TagId != objTag.TagId);
        }

        [HttpPost]
        [Route("Select")]
        public IHttpActionResult GetContents()
        {
            return Json("");
        }
    }
}
